<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /**
     * @param {string} s
     * @return {number}
     */
    var lengthOfLastWord = function(s) {
       let a = s.split(' ')
       let arr = []
       a.map((item,index)=>{
         if(item!='') arr.push(item)
       })
       if(arr.length==0) return 0
       return (arr[arr.length-1].length)
    };
    console.log(lengthOfLastWord('hello '))
  </script>
</html>
